﻿@model Paged<Post>

@if (Model.Any())
{
	foreach (var post in Model)
	{
		<article class="post">
			<h2>
				@Html.RouteLink(post.Title, "PostDetails", new
															   {
																   post.Id,
																   post.Slug
															   })
				<small>@post.Author.Name - @post.PublishedAt.ToReadableOffset(DateTime.UtcNow)</small>
			</h2>

			<div class="post-body">
				@Html.Raw(post.Body)
			</div>

			<div class="well">
				@if (post.Tags.Any())
				{
					<p class="tags">
						Tags
						@foreach (var tag in post.Tags)
						{
							<span class="label">@Html.RouteLink(tag.Name, "PostsByTag", new
																							{
																								tag.Slug
																							})</span>
						}
					</p>
				}

				<p class="comments">
					Comments
					<span class="badge">@Html.RouteLink(post.Comments.Count().ToString(), "PostDetails", null, null, "comments", new
																																	 {
																																		 id = post.Id
																																	 }, null)</span>
				</p>
			</div>
		</article>
	}

	@Html.Pagination(Model, new
								{
									@class = "visible-desktop"
								})

	@Html.PageSize(new
					   {
						   @class = "visible-desktop"
					   })

	@Html.PageNumber(Model, new
								{
									@class = "visible-tablet"
								})

	@Html.Pager(Model, new
						   {
							   @class = "visible-phone"
						   })
}
else
{
	<article>
		No results found.
	</article>
}